# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-sedlex
_pkgname=sedlex
pkgver=3.1
pkgrel=0
pkgdesc="An OCaml lexer generator for Unicode"
url="https://github.com/ocaml-community/sedlex"
arch="all !riscv64"  # limited by ocaml aport
license="MIT"
depends="ocaml-runtime ocaml-gen ocaml-ppxlib"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-gen-dev ocaml-ppxlib-dev"
makedepends="$depends_dev dune ocaml"
checkdepends="cmd:curl"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/ocaml-community/sedlex/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
27c7954c03a9d78f252167708afe7d91648ad3d3aa529e00c73da75bac49c2cf552cc9d27d29f1d9a04b1e2b47b7c6de9e9850c53124ad9f311d0a8f54bb9cae  ocaml-sedlex-3.1.tar.gz
"
